﻿using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Omu.ProDinner.WebUI.Controllers
{
    public class ChangeThemeController : Controller
    {
        private const string d = "start";
        private const string cookie = "pros";

        public ActionResult Index()
        {
            var t = d;
            if (Request.Cookies[cookie] != null)
                t = Request.Cookies[cookie].Value;

            var themes = new[] { "start", "black-tie", "smoothness", "redmond", "flick" };

            return View(themes.Select(o => new SelectListItem { Text = o, Value = o, Selected = o == t }));
        }

        [HttpPost]
        public ActionResult Change(string s)
        {
            Response.Cookies.Add(new HttpCookie(cookie, s) { Expires = DateTime.Now.AddDays(3) });
            return new EmptyResult();
        }

        public ActionResult CurrentTheme()
        {
            var s = d;
            if (Request.Cookies[cookie] != null)
                s = Request.Cookies[cookie].Value;

            return Content(s);
        }
    }
}